﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Configuration;
using System.Web;

/// <summary>
/// CMS_Util 的摘要说明
/// </summary>
public static class DATA_Util
{
    
    public static List<Dictionary<string, object>> DataTable2Dictionary(DataTable dataTable)
    {

        

        List<Dictionary<string, object>> result = new List<Dictionary<string, object>>();

        List<string> columns = new List<string>();

        foreach (DataColumn column in dataTable.Columns)
        {
            columns.Add(column.ColumnName);
        }
        
        foreach (DataRow row in dataTable.Rows)
        {
            Dictionary<string, object> item = new Dictionary<string, object>();

            foreach (string filedName in columns)
            {
                if(!Convert.IsDBNull(row[filedName]))
                    item.Add(filedName, row[filedName]);
            }

            result.Add(item);
        }

        return result;
    }

}
